/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package domain.controllers;

import domain.Entity.EntityUsuario;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import managers.InformeManager;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.servlet.view.RedirectView;

/**
 *
 * @author jorge
 */
public class borrarInformeController implements Controller{

    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
        ModelAndView mav = new ModelAndView();
        HttpSession session = request.getSession();
       EntityUsuario eu = (EntityUsuario) session.getAttribute("usuario");
        if(eu == null){
            mav.setView(new RedirectView("login.htm"));
            return mav;
        }else{
        InformeManager im = InformeManager.getInstance();
        
        long idInforme =  Integer.parseInt(request.getParameter("idInforme"));
        im.borrarInforme(idInforme);
        
        mav.setView(new RedirectView("mostrarInformes.htm"));
        return mav; 
        }
     }

}
